package com.bangbang.config;

import org.springframework.stereotype.Component;

import java.io.FileWriter;
import java.io.IOException;

/* *
 *类名：AlipayConfig
 *功能：基础配置类
 *详细：设置帐户有关信息及返回路径
 *修改日期：2017-04-05
 *说明：
 *以下代码只是为了方便商户测试而提供的样例代码，商户可以根据自己网站的需要，按照技术文档编写,并非一定要使用该代码。
 *该代码仅供学习和研究支付宝接口使用，只是提供一个参考。
 */
@Component
public class AlipayConfig {

//↓↓↓↓↓↓↓↓↓↓请在这里配置您的基本信息↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓

    // 应用ID,您的APPID，收款账号既是您的APPID对应支付宝账号
    public static String app_id = "2021000117688889";

    // 商户私钥，您的PKCS8格式RSA2私钥
    public static String merchant_private_key = "MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQC6t9r+Yz5/bQtWniJM44MTljVXzO4yg/R/1H5/ZlWt3a5SZpRLCFiAwiI67xk5NXvv68WgU88M16n646NKyKQfDinfXYN9jljcoie4+jbzpsHCUAw/o8G9Ou+mTo9DrjMrZicqvGjJL7RF0XjpxVs8A6AO5Iz2ZQMZrvpAJC0S1jKvdcXw4Dvg6uGTVv9Mp8N+n3aii+oMLv39laL27kFIIJgXhAE636vhuVnuMxG3wfMIwBK4Ayad6Il36/nauFBGJ2VZ/xEgOPSHyOHfY9XKjq9IDoJAiwFTXbxbzZBrQXDn4J2V9sBTGqdhOfXQmUdQZQIrg5hTlr1GwR2kLzBvAgMBAAECggEABWkMbHCdv/195Z2has7w3mFs3EVw5X/TVtzmaXSiqO4SfgrA40ezoM9/RGvnNDQrijEvwcyL5FhfcYilE6aqsserSPChvcKhKot8USzW6Mp9NM8y+6kYFQ6fIReHqTNkAi7slZ1t/95k/9zo/wUb9qo4OhY/S2hz5Yufbrpdn/0OGsGVRvD0Fpq8p5dNchnT5JDv+PtX5aGfpL1lW9/sTf21upIeKlaWsbd3E5KiwGpIMmk1HktLErwHmyKhnMMU1splKkd51dTWK4oRJo40/b7E4PXSIAfsU2M5HsIIGIGjDtjlqsgOw4mJPO5SXlgjLsDCtNEubvrHzikcmVsykQKBgQD/C3ZNq9lJAKZLXKDtGzGBHmueRzlGPVBnIs0q8MQZZALjr2SHLUW/3HDwY/bSsZskmMy8SBYvsVa6Qlbj0kLO6F/YOuRo4krZZGsoKrooRRQPr9fPxx59E71S3CzQ3yv5k4HYyQ3EjlhZ3WA4bDCCJF9+9mI4rJba3pYPv/EftwKBgQC7auGsPBlHU0hTkw9xlS7P3vHZ/D2gTnZYhkDWwen2kCD6VYpHtVXW8w/0qBEQX6jQOy+pAbtwyV7w45ZVVvVbXicASo+FJoSNIoZ6qqOJq0HrhyIx4z3TNDqQU2P4Oo+pJKd+4OYUOTFHp8TN4kBkQorGiJdudaGMRc2qNJ2FCQKBgAyqzhJngaA9lwTRMfD0082c7C1tTivt6atlsBj84lB8hiQ21uBb4EX6NeXKoTyvs4vqxuhnECsIPM19dAFWtRi/s9ryedu3uY34jdXt4VcUrz1kN2zLb/k4XMPbyaIKI43+xIk22yczBrJX62qB/RrJobCVniVAdTGjsoJPvzMbAoGBALphIif8ZE8wHV8vgk48Q59pYS6c0FRZcwu6B0UK9rbCwmjxJGEHjmQCuD1f3ghgeSsLkOwL0vHo8EeyrNAVeE7ypOp/O5b4pR0N1pqqk5PXAelOK81c5SDicdMRevtikXduAjwFQAmgjsdpqifs9og+PHAPajjpNkyfJlY7mOKxAoGBAI/VXoDp3PePUkwR76hscz1wOqo+HQc3HZztS95YwlckhYg9W97LodFu/h5UFduH6mxvlkX67ygMehOVbT7ae4MRpdB9ae//r24s2PdVuVH7k1APjafxAuqPmPoXENVLH0HNMTAMaVHZ0kXfq7RnpKvw+EVOK8i91eGuVrxyKFGo";

    // 支付宝公钥,查看地址：https://openhome.alipay.com/platform/keyManage.htm 对应APPID下的支付宝公钥。
    public static String alipay_public_key = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAnCqSZnNiMV6CQs0Yq3SsBl41pWfMmPE2mBDh2dxwapwu84pQ5hBUloQ1hCoF9cHYj1xHCyF46giQIaMZ9dJTrY2W/kMcUG/cJGoH7ZGUz689JevMTRpIyo9JiUHO/hE1dBVJer4Z39NWxLODEzwh3pnMORLMyZ4uTOACa/9Z0W8k3k7v49mOJbtSwwsCD1mflqtXmWdhnqRqZ1MFutnMZNRkHWJY1hHp0NpVmLVEKNh+nT7W7nwfZ55H7fiTAxqEit5n1RLWttNe2hMsu8McIs5vc7iIyAguzOs8p/vs4hUmdM2JFnM+1InzdcSgtBlmS7CztrsyE3TmaULB2czS0QIDAQAB";

    // 服务器异步通知页面路径  需http://格式的完整路径，不能加?id=123这类自定义参数，必须外网可以正常访问
    public static String notify_url = "http://4124381hi5.wicp.vip/callback/notifyUrl";

    // 页面跳转同步通知页面路径 需http://格式的完整路径，不能加?id=123这类自定义参数，必须外网可以正常访问
    public static String return_url = "http://4124381hi5.wicp.vip/callback/toSynchron";

    // 签名方式
    public static String sign_type = "RSA2";

    // 字符编码格式
    public static String charset = "utf-8";

    // 支付宝网关
    public static String gatewayUrl = "https://openapi.alipaydev.com/gateway.do";

    // 支付宝日志路径
    public static String log_path = "D:\\";


//↑↑↑↑↑↑↑↑↑↑请在这里配置您的基本信息↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑

    /**
     * 写日志，方便测试（看网站需求，也可以改成把记录存入数据库）
     * @param sWord 要写入日志里的文本内容
     */
    public static void logResult(String sWord) {
        FileWriter writer = null;
        try {
            writer = new FileWriter(log_path + "alipay_log_" + System.currentTimeMillis()+".txt");
            writer.write(sWord);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (writer != null) {
                try {
                    writer.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}

